//
//  PublicVC.m
//  TT
//
//  Created by Lenny on 16/4/19.
//  Copyright © 2016年 Lenny. All rights reserved.
//

#import "PublicVC.h"
#import "ChatV.h"
#import "WLMapV.h"

@interface PublicVC ()
{
    CGFloat _topHigh;
}
@property(nonatomic,strong)WLMapV *topV;
@property(nonatomic,strong)ChatV *chatV;

@end

@implementation PublicVC

#pragma mark - life cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self setData];
    [self UI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    [self.topV viewWillAppear];
}


- (void)viewWillDisappear:(BOOL)animated {
    
    [super viewWillDisappear:animated];
    [self.topV viewWillDisappear];
    self.topV = nil;
}


#pragma mark - private methods

- (void)setData {
    
    _topHigh = 200;
}

- (void)UI {
    
    [self.view addSubview:self.topV];
    [self.view addSubview:self.chatV];
    
    __weak typeof(self) weakSelf = self;
    [self.topV mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(_topHigh);
    }];
    
    [self.chatV mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(weakSelf.topV.mas_bottom);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.bottom.mas_equalTo(-k_M_Tabbar_h);
    }];
    
    [self.chatV addUI];
}

#pragma mark - setters and getters

- (WLMapV *)topV {
    
    if (_topV == nil) {
        
        _topV = [[WLMapV alloc] initWithFrame:CGRectMake(0, 0, k_screen_w, _topHigh)];
    }
    return _topV;
}

- (ChatV *)chatV {
    
    if (_chatV == nil) {
        
        _chatV = [[ChatV alloc] init];
    }
    return _chatV;
}

@end
